/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ee.cybertron.energon.components;

import com.icesoft.faces.component.ext.HtmlInputText;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ValueChangeEvent;
import javax.faces.event.ValueChangeListener;
import org.jdom.Element;

/**
 *
 * @author stevenziggiz
 */
public class CyberInputText extends HtmlInputText implements CyberComponent {

    private String tableReference;
    private String columnReference;
    private String dataType;
    private ValueChangeListener valueChangeListener;
    
    public CyberInputText() {
    }
    
    @Override
    public void excute(Element XMLComponent) {
        boolean edit;
        this.tableReference = XMLComponent.getAttributeValue("tableReference");
        this.columnReference = XMLComponent.getAttributeValue("columnReference");
        this.setValue(XMLComponent.getAttributeValue("value"));
        edit = Boolean.valueOf(XMLComponent.getAttributeValue("edit"));
        this.dataType = XMLComponent.getAttributeValue("type");
        this.setDisabled(!edit);
//        setPartialSubmit(true);
        valueChangeListener = new ValueChangeListener() {
            
            public void processValueChange(ValueChangeEvent vce) throws AbortProcessingException {
                setValue(vce.getNewValue());
            }
        };
        addValueChangeListener(valueChangeListener);
    }
    
    /**
     * @return the tableReference
     */
    public String getTableReference() {
        return tableReference;
    }

    /**
     * @param tableReference the tableReference to set
     */
    public void setTableReference(String tableReference) {
        this.tableReference = tableReference;
    }

    /**
     * @return the columnReference
     */
    public String getColumnReference() {
        return columnReference;
    }

    /**
     * @param columnReference the columnReference to set
     */
    public void setColumnReference(String columnReference) {
        this.columnReference = columnReference;
    }

    /**
     * @return the dataType
     */
    public String getDataType() {
        return dataType;
    }

    /**
     * @param dataType the dataType to set
     */
    public void setDataType(String dataType) {
        this.dataType = dataType;
    }    
}
